﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Brain.RPG2D
{
    public class PlayerSpawner : IDisposable
    {
        public Sprite SpawnLocation;

        public PlayerSpawner()
        {
            SpawnLocation = new Sprite();
            SpawnLocation.Rendering = SpriteRendering.EditorVisible;
            SpawnLocation.Color = new Color(255, 0, 0);
            SpawnLocation.BoundsRectangle = new Rectangle(0, 0, 32, 32);

            RPGLevelManager manager = Engine.Instance.GetManager<RPGLevelManager>();
            if (manager != null)
            {
                if (manager.CurrentLevel.Spawner != null)
                {
                    manager.CurrentLevel.Spawner.Dispose();
                }
                manager.CurrentLevel.Spawner = this;
            }
            else
            {
                throw new Exception("RPG System not fully loaded");
            }
        }
        public void Dispose()
        {
            SpawnLocation.Rendering = SpriteRendering.Invisible;
            SpawnLocation = null;
        }
    }
}
